home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 11 / Cream of the Crop 11-1.iso / comm / ftp4w24b.zip / vb / ftp4w.bas < prev    next >
BASIC Source File  |  1995-01-20  |  8KB  |  187 lines

  1. 'declarations for FTP module to use with FTP4W
  2. 'and retrieved from FTP4W.h
  3. 'origin : Ph. Jounin (SNCF 71-26-12)
  4. '         Internet ark@ifh.sncf.fr
  5. '
  6. 'coded    : 30/12/94
  7. 'by       : C. de Rooij
  8. 'version  : 1.1
  9. 'changed  : 16/01/95 some parameters called By value
  10. '
  11. Global Const FTP_DATABUFFER = 4096 'a good value for X25/Ethernet/Token Ring
  12. '-----------------------------------------------------------
  13. 'ASCII or binary tranfser
  14. Global Const TYPE_A = "A"    'should be used with Asc(TYPE_A)
  15. Global Const TYPE_I = "I"    'or Asc(TYPE_I)
  16. '
  17. '-----------------------------------------------------------
  18. '              Return codes of FTP functions
  19. '-----------------------------------------------------------
  20. Global Const FTPERR_OK = 0                  'succesful function
  21. Global Const FTPERR_ENTERPASSWORD = 1       'userid need a password
  22. Global Const FTPERR_ACCOUNTNEEDED = 2       'user/pass OK but account required
  23. Global Const FTPERR_CANCELBYUSER = -1       'Transfer aborted by user FtpAbort
  24. 'user's or programmer's Errors
  25. Global Const FTPERR_INVALIDPARAMETER = 1000 'Error in parameters
  26. Global Const FTPERR_SESSIONUSED = 1001      'User has already a FTP session
  27. Global Const FTPERR_NOTINITIALIZED = 1002   'FtpInit has not been call
  28. Global Const FTPERR_NOTCONNECTED = 1003     'User is not connected to a server
  29. Global Const FTPERR_CANTOPENFILE = 1004     'can not open specified file
  30. Global Const FTPERR_CANTWRITE = 1005        'can't write into file (disk full?)
  31. Global Const FTPERR_NOACTIVESESSION = 1006  'FtpRelease without FtpInit
  32. Global Const FTPERR_STILLCONNECTED = 1007   'FtpRelease without any Close
  33. Global Const FTPERR_SERVERCANTEXECUTE = 1008'file action not taken
  34. Global Const FTPERR_LOGINREFUSED = 1009     'Server rejects usrid/passwd
  35. Global Const FTPERR_NOREMOTEFILE = 1010     'server can not open file
  36. Global Const FTPERR_TRANSFERREFUSED = 1011  'Host refused the transfer
  37. Global Const FTPERR_WINSOCKNOTUSABLE = 1012 'A winsock.DLL ver 1.1 is required
  38. Global Const FTPERR_CANTCLOSE = 1013         'close failed (cmd is in progress)
  39. '* TCP errors
  40. Global Const FTPERR_UNKNOWNHOST = 2001      'can not resolve host adress
  41. Global Const FTPERR_NOREPLY = 2002          'host does not send an answer
  42. Global Const FTPERR_CANTCONNECT = 2003      'Error during connection
  43. Global Const FTPERR_CONNECTREJECTED = 2004  'host has no FTP server
  44. Global Const FTPERR_SENDREFUSED = 2005      'can't send data (network down)
  45. Global Const FTPERR_DATACONNECTION = 2006   'connection on data-port failed
  46. Global Const FTPERR_TIMEOUT = 2007          'timeout occurred
  47. '* FTP errors
  48. Global Const FTPERR_UNEXPECTEDANSWER = 3001 'answer was not expected
  49. Global Const FTPERR_CANNOTCHANGETYPE = 3002 'host rejects the TYPE command
  50. '* Resource errors
  51. Global Const FTPERR_CANTCREATEWINDOW = 5002 'Insufficent free resources
  52. Global Const FTPERR_INSMEMORY = 5003        'Insufficient Heap memory
  53. Global Const FTPERR_CANTCREATESOCKET = 5004 'no more socket
  54. Global Const FTPERR_CANTBINDSOCKET = 5005   'bind is not succesful
  55. '
  56. '* ****************************************************************
  57. '*
  58. '*                    P R O T O T Y P E S
  59. '*
  60. '* ****************************************************************
  61. '* Init functions
  62. '
  63. Declare Function FtpInit Lib "FTP4W.DLL" (ByVal HWND As Integer) As Integer
  64. Declare Function FtpRelease Lib "FTP4W.DLL" () As Integer
  65. '
  66. '* Connection
  67. '
  68. Declare Function FtpLogin Lib "FTP4W.DLL" (ByVal Host As String, ByVal User As String, ByVal Password As String, ByVal HWND As Integer, ByVal msge As Integer) As Integer
  69. Declare Function FtpOpenConnection Lib "FTP4W.DLL" (ByVal Host As String) As Integer
  70. Declare Function FtpCloseConnection Lib "FTP4W.DLL" () As Integer
  71. Declare Function FtpLocalClose Lib "FTP4W.DLL" () As Integer
  72. '
  73. '* authentification
  74. '
  75. Declare Function FtpSendUserName Lib "FTP4W.DLL" (ByVal UserName As String) As Integer
  76. Declare Function FtpSendPasswd Lib "FTP4W.DLL" (ByVal Passwd As String) As Integer
  77. '
  78. '* commands
  79. '
  80. Declare Function FtpHelp Lib "FTP4W.DLL" (ByVal Arg As String, ByVal Buf As String, ByVal BufSize As Integer) As Integer
  81. Declare Function FtpCWD Lib "FTP4W.DLL" (ByVal Path As String) As Integer
  82. Declare Function FtpQuote Lib "FTP4W.DLL" (ByVal Cmd As String, ByVal ReplyBuf As String, ByVal BufSize As Integer) As Integer
  83. Declare Function FtpSetType Lib "FTP4W.DLL" (ByVal Typ As Integer) As Integer  '
  84. '
  85. '* file transfer
  86. '
  87. Declare Function FtpAbort Lib "FTP4W.DLL" () As Integer
  88. 'how to handle 3rd parameter see also FtpSetType
  89. Declare Function FtpSendFile Lib "FTP4W.DLL" (ByVal Lcl As String, ByVal Remote As String, ByVal Typ As Integer, ByVal Notify As Integer, ByVal HWND As Integer, ByVal msge As Integer) As Integer
  90. Declare Function FtpRecvFile Lib "FTP4W.DLL" (ByVal Remote As String, ByVal Lcl As String, ByVal Typ As Integer, ByVal Notify As Integer, ByVal HWND As Integer, ByVal msge As Integer) As Integer
  91. '
  92. Declare Function FtpGetFileSize Lib "FTP4W.DLL" () As Long
  93. '
  94. '* Directory
  95. '
  96. Declare Function FtpDir Lib "FTP4W.DLL" (ByVal Def As String, ByVal LocalFile As String, ByVal LongDir As Integer, ByVal HWND As Integer, ByVal msge As Integer) As Integer
  97. '
  98. '* specials
  99. '
  100. Declare Function FtpBytesTransfered Lib "FTP4W.DLL" () As Long
  101. Declare Function FtpBytesToBeTransfered Lib "FTP4W.DLL" () As Long
  102. Declare Sub FtpSetDefaultTimeOut Lib "FTP4W.DLL" (ByVal nTo_in_sec As Integer)
  103. Declare Sub FtpSetDefaultPort Lib "FTP4W.DLL" (ByVal nDefPort As Integer)
  104. Declare Sub FtpSetAsynchronousMode Lib "FTP4W.DLL" ()
  105. Declare Sub FtpSetSynchronousMode Lib "FTP4W.DLL" ()
  106. Declare Function FtpIsAsynchronousMode Lib "FTP4W.DLL" () As Integer
  107. Declare Sub FtpSetNewDelay Lib "FTP4W.DLL" (ByVal X As Integer)
  108. Declare Sub FtpSetNewSlices Lib "FTP4W.DLL" (ByVal X As Integer, ByVal Y As Integer)
  109. '
  110. '* Utilities functions
  111. '
  112. Declare Function WEP Lib "FTP4W.DLL" (ByVal nType As Integer) As Integer
  113. Declare Function FtpSetVerboseMode Lib "FTP4W.DLL" (ByVal bVerBoseMode As Integer, ByVal HWND As Integer, ByVal wMsg As Integer) As Integer
  114. '
  115.  
  116. Function FTP4W_Error (ErrorValue As Integer) As String
  117.   'return a string related to the ErrorValue given
  118.   'as a parameter
  119.   '
  120.   Dim Msg$
  121.   '
  122.   Select Case ErrorValue
  123.    Case FTPERR_ENTERPASSWORD
  124.      Msg$ = "Userid need a password"
  125.    Case FTPERR_ACCOUNTNEEDED
  126.      Msg$ = "User/pass OK but account required"
  127.    Case FTPERR_CANCELBYUSER
  128.      Msg$ = "Transfer aborted by user FtpAbort"
  129.    Case FTPERR_INVALIDPARAMETER
  130.      Msg$ = "Error in parameters"
  131.    Case FTPERR_SESSIONUSED
  132.      Msg$ = "User has already a FTP session"
  133.    Case FTPERR_NOTINITIALIZED
  134.      Msg$ = "FtpInit has not been called"
  135.    Case FTPERR_NOTCONNECTED
  136.      Msg$ = "User is not connected to a server"
  137.    Case FTPERR_CANTOPENFILE
  138.      Msg$ = "Can not open specified file"
  139.    Case FTPERR_CANTWRITE
  140.      Msg$ = "Can't write into file (disk full?)"
  141.    Case FTPERR_NOACTIVESESSION
  142.      Msg$ = "FtpRelease without FtpInit"
  143.    Case FTPERR_STILLCONNECTED
  144.      Msg$ = "FtpRelease without any Close"
  145.    Case FTPERR_SERVERCANTEXECUTE
  146.      Msg$ = "File action not taken"
  147.    Case FTPERR_LOGINREFUSED
  148.      Msg$ = "Server rejects Userid/Passwd"
  149.    Case FTPERR_NOREMOTEFILE
  150.      Msg$ = "Server can not open file"
  151.    Case FTPERR_TRANSFERREFUSED
  152.      Msg$ = "Host refused the transfer"
  153.    Case FTPERR_WINSOCKNOTUSABLE
  154.      Msg$ = "A winsock.DLL version 1.1 is required"
  155.    Case FTPERR_UNKNOWNHOST
  156.      Msg$ = "Can not resolve host address"
  157.    Case FTPERR_NOREPLY
  158.      Msg$ = "Host does not send an answer"
  159.    Case FTPERR_CANTCONNECT
  160.      Msg$ = "Error during connection"
  161.    Case FTPERR_CONNECTREJECTED
  162.      Msg$ = "Host has no FTP server"
  163.    Case FTPERR_SENDREFUSED
  164.      Msg$ = "Can't send data (network down)"
  165.    Case FTPERR_DATACONNECTION
  166.      Msg$ = "Connection on data-port failed"
  167.    Case FTPERR_TIMEOUT
  168.      Msg$ = "Timeout occurred"
  169.    Case FTPERR_UNEXPECTEDANSWER
  170.      Msg$ = "Answer was not expected"
  171.    Case FTPERR_CANNOTCHANGETYPE
  172.      Msg$ = "Host rejects the TYPE command"
  173.    Case FTPERR_CANTCREATEWINDOW
  174.      Msg$ = "Insufficent free resources"
  175.    Case FTPERR_INSMEMORY
  176.      Msg$ = "Insufficient Heap memory"
  177.    Case FTPERR_CANTCREATESOCKET
  178.      Msg$ = "No more socket"
  179.    Case FTPERR_CANTBINDSOCKET
  180.      Msg$ = "Bind is not succesful"
  181.   End Select
  182.   '
  183.   FTP4W_Error = Msg$
  184.   '
  185. End Function
  186.  
  187.